#include<iostream>
#include<string>
using namespace std;
const int N = 1e5+10;
typedef long long ll;
ll a[N];
ll s[N];   //前缀和数组
int main()
{
    ll n, m;
    cin >> n >> m;
    for (ll i = 1; i <= n; i++) cin >> a[i];
    //计算前缀和
    s[0] =0;
    for (ll i = 1; i <= n; i++)
        s[i] = s[i - 1]+ a[i];
    //计算子区间[l,r]   l>=1  如果>=0 另外写
    while (m--)
    {
        ll l, r;
        cin >> l >> r;
        cout << s[r] - s[l-1] << endl;
    }
    return 0;
}